package sanmubird.club.mock.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sanmubird.club.mock.dao.beans.UserConverter;
import sanmubird.club.mock.dao.beans.UserDTO;
import sanmubird.club.mock.dao.beans.UserPo;
import sanmubird.club.mock.dao.orm.UserRepository;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Sam
 */
@Service
public class UserService {

	@Autowired
	private UserRepository userRepository;

	@Autowired
	private UserConverter userConverter;

	public List<UserDTO> selectList(UserDTO userDTO) {
		UserPo userPo = userConverter.dtoToPo(userDTO);
		List<UserPo> userPos = userRepository.selectList(userPo);
		return userPos.stream().map(po -> userConverter.poToDTO(po)).collect(Collectors.toList());
	}
}
